package com.slz3.business.module.wmsManagement.wmsWarehouseManage.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDate;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class WmsWarehouseManageEntity extends DomainEntity {

    /**
     * 编号
     */
    @Column(length = 80)
    @NotNull(message = "serNum 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 80, message = "ser2 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;

    /**
     * 审核状态
     */
    @Enumerated(STRING)
    @NotNull(message = "serAudit 必须非空!", groups = {Add.class})
    @Null(message = "serAudit 必须为空!", groups = {Modify.class})
    private AuditFlag serAudit;

    /**
     * 启用状态
     */
    @Enumerated(STRING)
    @NotNull(message = "serUsing 必须非空!", groups = {Add.class})
    @Null(message = "serUsing 必须为空!", groups = {Modify.class})
    private UsingFlag serUsing;

    /**
     * 仓库名称
     */
    @NotBlank(message = "serName 必须非空!", groups = {Add.class,Modify.class})
    private String serName;

    /**
     * 联系人
     */
    @NotBlank(message = "serLinkman 必须非空!", groups = {Add.class,Modify.class})
    private String serLinkman;

    /**
     * 联系人方式
     */
    @NotBlank(message = "serContact 必须非空!", groups = {Add.class,Modify.class})
    private String serContact;

    /**
     * 所在地区
     */
    @NotNull(message = "serArea 必须非空!", groups = {Add.class,Modify.class})
    @Enumerated(STRING)
    private WareHouseAreaEnum serArea;

    /**
     * 详细地址
     */
    @NotBlank(message = "serAddress 必须非空!", groups = {Add.class,Modify.class})
    private String serAddress;

    /**
     * 仓库类型
     */
    @Enumerated(STRING)
    private WareAreaTypeEnum serAreaType;

    /**
     * 仓库类型
     */
    @Enumerated(STRING)
    private WareTypeEnum serWmsType;

    /**
     * 标签
     */
    private String serLabels;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate serInputGroupData;

}
